<script type="text/javascript" src="/js/monitor.js"></script>
<style>
  table.data th {
    background-color:#888888;
    border-bottom-color:#333333;
    border-bottom-style:solid;
    border-bottom-width:1px;
    color:#FFFFFF;
    font-weight:400;
  }
  table.data td {
    background-color:#FFFFFF;
    border-bottom-color:#EBEBEB;
    border-bottom-style:solid;
    border-bottom-width:1px;
  }
  table.data td .down {
    color:#008000;
  }
  table.data td .up {
    color:#FF0000;
  }
</style>

<table class="data" width="50%" border="0" cellpadding="10" cellspacing="0">
  <tr>
    <th>Name</th>
    <th>Code</th>
    <th>Current</th>
    <th>Increase</th>
    <th>Percent</th>
    <th>Top Limit</th>
    <th>Lower Limit</th>
    <th>Alarm</th>
    <th>Action</th>
  </tr>
<?php
  foreach ($monitor_list as $row) {
    if ($row->getMyStock()->getIncreasePercent() > 0) {
      $class = "up";
    } else if ($row->getMyStock()->getIncreasePercent() < 0) {
      $class = "down";
    } else {
      $class = "";
    }

    $profit_price = 0 == $row->getProfitPrice() ? '' : $row->getProfitPrice();
    $loss_price   = 0 == $row->getLossPrice() ? '' : $row->getLossPrice();
?>
  <tr>
    <td><?php echo $row->getMyStock()->getName(); ?></td>
    <td><?php echo $row->getCode() ?></td>
    <td><?php echo $row->getMyStock()->getCurrent(); ?></td>
    <td><span class="<?php echo $class;?>"><?php echo $row->getMyStock()->getIncrease() ?></span></td>
    <td><span class="<?php echo $class;?>"><?php echo $row->getMyStock()->getIncreasePercent(); ?>%</span></td>
    <td>
      <span class="profit"><?php echo $profit_price; ?></span>
      <input type="text" style="display:none" name="top" value="<?php echo $profit_price ?>" class="edit_top" size="5">
    </td>
    <td>
      <span class="loss"><?php echo $loss_price; ?></span>
      <input type="text" style="display:none" name="lower" value="<?php echo $loss_price ?>" class="edit_lower" size="5">
    </td>
    <td>
      <span class="alarm"><?php echo $row->getStatus() ? 'Yes' : 'No'; ?></span>
      <select name="alarm" style="display:none" class="edit_alarm">
        <option value="1" <?php echo $row->getStatus() ? 'selected="selected"':''; ?>>Yes</option>
        <option value="0" <?php echo !$row->getStatus() ? 'selected="selected"':''; ?>>No</option>
      </select>
    </td>
    <td>
      <input type="button" value="Edit" class="edit_btn">
      <input type="button" value="Save" class="save_btn" style="display:none" id ="<?php echo $row->getId() ?>">
      <input type="button" value="Delete" class="del_btn" id ="<?php echo $row->getId() ?>">
    </td>
  </tr>
<?php } ?>
  <tr>
    <td></td>
    <td><input type="text" size="10" name="code" id="stockcode"></td>
    <td></td>
    <td></td>
    <td><input type="text" size="5" name="top" id="top_price"></td>
    <td><input type="text" size="5" name="lower" id="lower_price"></td>
    <td></td>
    <td><input type="button" value="Add" id="add_btn"></td>
  </tr>
</table>

